﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TicketMovie.Admin
{
    public partial class WebForm13 : System.Web.UI.Page
    {
        private DataClasses1DataContext dc = new DataClasses1DataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        protected void Button_Click(object sender, EventArgs e)
        {
            double kichthuoc = (double)this.FileUpload1.FileBytes.Count() / 1024 / 1024;
            string filenamebefore = this.FileUpload1.FileName;
            if (!filenamebefore.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) && !filenamebefore.EndsWith("gif", StringComparison.OrdinalIgnoreCase) && !filenamebefore.EndsWith("png", StringComparison.OrdinalIgnoreCase))
                this.Label1.Text = "Invalid file format!";
            else
            {
                if (kichthuoc > 1)
                    this.Label1.Text = "File size too large!!";
                else
                {
                    string filenames = DateTime.Now.ToString("yyyyMMddHHmmss") + this.FileUpload1.FileName;
                    this.FileUpload1.SaveAs(Server.MapPath("img/posters/" + filenames));

                }
            }  
        }
    }
}